.minesweeper {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: Arial, sans-serif;
  padding: 20px;
  box-sizing: border-box;
  max-width: 100%;
  overflow-x: hidden;
}

.game-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 500px;
  margin-bottom: 20px;
  box-sizing: border-box;
  min-height: 70px; /* Ensure consistent height */
}

.mines-counter, .timer {
  font-size: 24px;
  font-weight: bold;
  background-color: #333;
  color: #fff;
  padding: 10px 20px;
  border-radius: 4px;
  box-sizing: border-box;
  min-width: 120px; /* Ensure consistent width */
  text-align: center;
}

.reset-button {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background-color: #ddd;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin: 0 20px; /* Add horizontal margin */
}

.difficulty-selector {
  margin-bottom: 20px;
  width: 100%;
  text-align: center;
  min-height: 40px; /* Ensure consistent height */
}

.difficulty-selector button {
  padding: 10px 15px;
  margin: 5px;
  border: none;
  background-color: #ddd;
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
}

.difficulty-selector button.active {
  background-color: #4CAF50;
  color: white;
}

.custom-settings {
  margin-top: 15px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 15px;
  padding: 15px;
  background-color: #f0f0f0;
  border-radius: 8px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.setting-group label {
  font-weight: bold;
  margin-bottom: 5px;
}

.custom-input {
  width: 70px;
  padding: 8px;
  border: 1px solid #999;
  border-radius: 4px;
  text-align: center;
}

.mine-range {
  margin-left: 5px;
  font-size: 14px;
  color: #666;
}

.board {
  display: grid;
  gap: 1px;
  background-color: #bbb;
  border: 2px solid #bbb;
  padding: 2px;
  border-radius: 4px;
  margin: 0 auto;
  position: relative;
  box-sizing: content-box;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.cell {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #ddd;
  border: 1px solid #bbb;
  font-weight: bold;
  cursor: pointer;
  user-select: none;
  position: relative;
  box-sizing: border-box;
}

.cell.visible {
  border: 1px solid #999;
  background-color: #eee;
}

.cell.highlight {
  box-shadow: inset 0 0 0 2px #4CAF50;
}

.cell.flagged::before {
  content: "🚩";
  position: absolute;
  z-index: 1;
}

.cell.adjacent-1 { color: #0000ff; }
.cell.adjacent-2 { color: #008000; }
.cell.adjacent-3 { color: #ff0000; }
.cell.adjacent-4 { color: #000080; }
.cell.adjacent-5 { color: #800000; }
.cell.adjacent-6 { color: #008080; }
.cell.adjacent-7 { color: #000000; }
.cell.adjacent-8 { color: #808080; }

.message {
  margin-top: 20px;
  font-size: 24px;
  font-weight: bold;
  height: 36px; /* Fixed height to prevent layout shift */
  min-height: 36px;
  text-align: center;
}

/* Ensure consistent layout */
.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}